//
//  MBDGroupLogoCellModel.swift
//  MasterBoy
//
//  Created by kyson on 2024/8/27.
//

import Foundation

import YYText


class MBDGroupLogoCellModel : MBDGroupDetailCommonCellModel {
    var groupDetailTextLayout : YYTextLayout?
    var groupCoverURL : String!
    
    static let GroupLogoHeight : CGFloat = 160

    override var groupDetail: MBDGroupDetailModel! {
        didSet {
            let groupInfo = self.groupDetail.groupName!
            let groupDetailAttributeString = NSMutableAttributedString(string: groupInfo )
            groupDetailAttributeString.yy_font = UIFont.boldSystemFont(ofSize: 24)
            groupDetailAttributeString.yy_lineSpacing = 4
            groupDetailAttributeString.yy_alignment = .center
            groupDetailAttributeString.setDynamicTextColor()
            
            let groupDetailContainer = YYTextContainer()
            
            let groupDetailWidth = CGRectGetWidth(UIScreen.main.bounds) - MBDGroupLogoCellModel.MarginLeftAndRightBackgroundView * 2
            groupDetailContainer.size = CGSizeMake(groupDetailWidth , CGFLOAT_MAX)
            let groupDetailLayout = YYTextLayout(container: groupDetailContainer, text: groupDetailAttributeString)
            
            self.groupDetailTextLayout = groupDetailLayout
            
            self.groupCoverURL = MBDPath2URLUtils.wrapGroupLogoURL(path: self.groupDetail.groupLogo)

        }
    }
    
    override func cellHeight() -> CGFloat {
        return MBDGroupLogoCellModel.GroupLogoHeight
    }
}
